public class Test {
    public static int remove(int[] nums){
       int n = nums.length;
        for (int i = 0; i < n-1 ; i++) {
            if(nums[i] == nums[i+1]){
                for (int j = i; j < n-1; j++) {
                     nums[j] = nums[j+1];
                }
                n--;
                i--;
            }
        }
        return n;
    }
    public static void main(String[] args){
        int[] nums = { 1,1,2,2,3,4};
       int n = remove(nums);
        for (int i = 0; i < n; i++) {
            System.out.println(nums[i]);
        }
    }
}
